﻿@{
    Layout = "_EmptyLayout";
    ViewData["Title"] = "处理会议审核信息";
}
<form class="layui-form layui-form-pane" action="" lay-filter="ShowHandleConventionApply" style="margin: 15px 20px">
    <div class="layui-form-item">
        <label class="layui-form-label">申请人</label>
        <div class="layui-input-block">
            <input type="text" name="proposerName" lay-verify="title" autocomplete="off" class="layui-input" disabled>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">申请人电话</label>
        <div class="layui-input-block">
            <input type="text" name="proposerPhone" lay-verify="title" autocomplete="off" class="layui-input" disabled>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">申请人部门</label>
        <div class="layui-input-block">
            <input type="text" name="proposerSection" autocomplete="off" class="layui-input" disabled>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">会议地点</label>
        <div class="layui-input-block">
            <input type="text" name="place" autocomplete="off" class="layui-input" disabled>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">开始时间</label>
        <div class="layui-input-block">
            <input type="text" name="startTime" autocomplete="off" class="layui-input" disabled>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">结束时间</label>
        <div class="layui-input-block">
            <input type="text" name="endTime" autocomplete="off" class="layui-input" disabled>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">审批结果</label>
        <div class="layui-input-inline">
            <select name="currentState" id="currentState">
                <option value="正在审核">正在审核</option>
                <option value="通过申请">通过申请</option>
                <option value="已被拒绝">已被拒绝</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <button class="layui-btn layui-btn-fluid" lay-submit="" lay-filter="handleSubmit" id="button">确认</button>
    </div>
</form>

@section Scripts{
    <script src="~/layui-v2.5.5/layui/layui.all.js" charset="utf-8"></script>
    <script src="~/js/jquery.js"></script>
    <script>
        layui.use(['form', 'layedit', 'laydate'], function () {
            var form = layui.form
                , layer = layui.layer
                , conventionData = "";
                //表单赋值
                $.ajax({
                url: '/Api/ShowConvention',
                data: { id: @ViewData["HCID"] },
                type: "GET",
                dataType: "JSON",
                success: function (data) {
                    switch (data.code) {
                        //会议信息
                        case 200:
                            conventionData = data;
                            form.val('ShowHandleConventionApply', {
                            "proposerName": conventionData.conventionDetail.proposerName
                            , "proposerPhone": conventionData.conventionDetail.proposerPhone
                            , "proposerSection": conventionData.conventionDetail.proposerSection
                            , "place": conventionData.conventionDetail.place
                            , "startTime": conventionData.conventionDetail.startTime
                            , "endTime": conventionData.conventionDetail.endTime
                            , "currentState": conventionData.conventionDetail.currentState
                            });
                            break;
                        case 270:
                            layer.alert("数据异常，你再试试呗", { icon: 3 });
                            break;
                        default:
                            layer.alert("数据异常，你再试试呗", { icon: 3 });
                    }
                    if (conventionData.conventionDetail.currentState != "正在审核") {
                        var DomClass = document.getElementById("button").className;
                        DomClass = DomClass.replace('layui-btn',"layui-btn layui-btn-disabled");
                        document.getElementById("button").className = DomClass;
                    }
                }
                })
                //监听提交
            form.on('submit(handleSubmit)', function (data) {
                console.log(data);
                    //提交修改数据
                    $.ajax({
                        url: '/Api/SubmitHandleConventionApply',
                        data: {
                            id: @ViewData["HCID"],
                            state: data.field.currentState
                        },
                        type: "POST",
                        dataType: "JSON",
                        success: function (data) {
                            switch (data.code) {
                                case 0:
                                    layer.msg("审批成功，", { icon: 1 }, { time: 500 });
                                    setTimeout(function () {
                                        parent.window.location.reload();
                                    }, 500);
                                    break;
                                case 270:
                                    layer.alert("审批失败，",{ icon: 2 });
                                    break;
                                default:
                                    layer.alert("数据异常，你再试试呗", { icon: 3 });
                            }
                        },
                    })
                    return false;
                });
        });
    </script>
}
